package it.avantsoft.ls.peer.message;

import java.io.DataOutputStream;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: blackmore
 * Date: 23-lug-2008
 * Time: 15.41.13
 * To change this template use File | Settings | File Templates.
 */
public class HorizontalExchangeablePeerMessage extends PeerMessage {
    private String exchangeablePeer;
    private String designedGroupLeaderId;

    public HorizontalExchangeablePeerMessage(DataOutputStream out, String exchangeablePeerHost, String designedGroupLeaderId) {
        super(out);
        this.exchangeablePeer = exchangeablePeerHost;
        this.designedGroupLeaderId = designedGroupLeaderId;
    }

    public boolean send() {
        boolean sent = false;
        try {
            writeByte(HORIZONTALEXCHANGEABLEPEER);
            writeUTF(exchangeablePeer);
            writeUTF(designedGroupLeaderId);
            flush();
            sent = true;
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return sent;  //To change body of implemented methods use File | Settings | File Templates.
    }


    public String toString() {
        return "HorizontalExchangeablePeerMessage{" +
                "exchangeablePeer='" + exchangeablePeer + '\'' +
                '}';
    }
}
